<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>
  File: README
  
    &mdash; Documentation by YARD 0.8.7
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '';
  framesUrl = "frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index</a> &raquo; 
    <span class="title">File: README</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><div id='filecontents'>
<h1 id="label-Foreman+API+bindings+for+Ruby">Foreman API bindings for Ruby</h1>

<h2 id="label-Summary">Summary</h2>

<p>Usage:</p>

<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foreman_api</span><span class='tstring_end'>&#39;</span></span>
<span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>logger</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># optional
</span>
<span class='id identifier rubyid_architectures'>architectures</span> <span class='op'>=</span> <span class='const'>ForemanApi</span><span class='op'>::</span><span class='const'>Resources</span><span class='op'>::</span><span class='const'>Architecture</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
  <span class='lbrace'>{</span>
    <span class='symbol'>:logger</span> <span class='op'>=&gt;</span> <span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>STDOUT</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='comment'># optional
</span>    <span class='symbol'>:base_url</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://foreman-url</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> 
    <span class='symbol'>:username</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>admin</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> 
    <span class='symbol'>:password</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>changeme</span><span class='tstring_end'>&#39;</span></span>
  <span class='rbrace'>}</span><span class='rparen'>)</span>

<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_architectures'>architectures</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
</code></pre>

<h2 id="label-Description">Description</h2>

<p>This gem contains Foreman API bindings for the Ruby language. The bindings
are generated from API documentation using <a
href="https://github.com/Pajk/apipie-rails">Apidoc</a> tool.</p>

<p>The bindings brings support for new versioned API which is not complete
yet. The number of supported controllers is limited but more are coming
soon.</p>

<h3 id="label-Regenerating+bindings">Regenerating bindings</h3>

<p>The code for generating the bindings is a part of this repo. The generator
needs a running Foreman instance to load the apidoc.json.</p>

<p>Usage:</p>

<pre class="code ruby"><code class="ruby">bin/generate.rb -h
Script for generating API bindings for Foreman API from Apipie docs.
    -u, --url FOREMAN_APIDOC_URL     By default http://localhost:3000/apidoc
    -h, --help</code></pre>

<p>Only files under <code>lib/foreman_api/resources</code> are touched by the
generator.</p>

<h3 id="label-Authentication">Authentication</h3>

<p>Foreman API uses OAuth for authentication, you need to provide url, key and
secret. Also, it is required to provide user which will be used for the
request if oauth_map_users setting in the Foreman instance is set,
otherwise 401 error will occur and Foreman log will state “users mapping
error”.</p>

<p>When setting base_url make sure it *does not* include trailing slash,
otherwise request can be refused with 401.</p>

<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foreman_api</span><span class='tstring_end'>&#39;</span></span>

<span class='id identifier rubyid_architectures'>architectures</span> <span class='op'>=</span> <span class='const'>ForemanApi</span><span class='op'>::</span><span class='const'>Resources</span><span class='op'>::</span><span class='const'>Architecture</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
  <span class='lbrace'>{</span>
    <span class='symbol'>:base_url</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://foreman-url</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> 
    <span class='symbol'>:oauth</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
      <span class='symbol'>:consumer_key</span>    <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>katello</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
      <span class='symbol'>:consumer_secret</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>shhhh</span><span class='tstring_end'>&quot;</span></span> 
    <span class='rbrace'>}</span>
  <span class='rbrace'>}</span><span class='comma'>,</span><span class='lbrace'>{</span>
    <span class='symbol'>:headers</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
      <span class='symbol'>:foreman_user</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>admin</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
    <span class='rbrace'>}</span>
  <span class='rbrace'>}</span><span class='rparen'>)</span>

<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_architectures'>architectures</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
</code></pre>

<h2 id="label-License">License</h2>

<p>The bindings are released under MIT license</p>
</div></div>

    <div id="footer">
  Generated on Thu Jan 23 15:40:31 2014 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7 (ruby-2.0.0).
</div>

  </body>
</html>